package com.example.nightmeel.loader;

import java.util.List;

import com.example.nightmeel.db.TimeLineData;

import android.app.LoaderManager.LoaderCallbacks;
import android.content.Loader;
import android.os.Bundle;

public class TimeLineLoaderCallbacks implements LoaderCallbacks<List<TimeLineData>> {

    private static final String TAG = TimeLineLoaderCallbacks.class.getSimpleName();
    private final TimeLineLoaderCallbacks self = this;

    private EventListener mEventListener = null;

    /**
     * コンストラクタ.
     * @param callbacks
     */
    public TimeLineLoaderCallbacks (EventListener callbacks) {
        mEventListener = callbacks;
    }

    @Override
    public Loader<List<TimeLineData>> onCreateLoader(int arg0, Bundle arg1) {
        // コールバックを実行。実装はActivityで。
        return mEventListener.onCreateLoader(arg0, arg1);
    }

    @Override
    public void onLoadFinished(Loader<List<TimeLineData>> arg0, List<TimeLineData> arg1) {
        mEventListener.onLoadFinished(arg0, arg1);
    }

    @Override
    public void onLoaderReset(Loader<List<TimeLineData>> arg0) {
        mEventListener.onLoaderReset(arg0);
    }

    public interface EventListener {
        public Loader<List<TimeLineData>> onCreateLoader(int arg0, Bundle arg1);
        public void onLoadFinished(Loader<List<TimeLineData>> arg0, List<TimeLineData> arg1);
        public void onLoaderReset(Loader<List<TimeLineData>> arg0);
    }
}
